function scrollFix(elem) {
  // Variables to track inputs
  let startTopScroll

  // If there is no element, then do nothing
  if (!elem) return

  // Handle the start of interactions
  elem.addEventListener('touchstart', () => {
    startTopScroll = elem.scrollTop

    if (startTopScroll <= 0) {
      elem.scrollTop = 1
    }

    if (startTopScroll + elem.offsetHeight >= elem.scrollHeight) {
      elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1
    }
  }, false)
}


export default scrollFix
